#include <SeqJacobi.hpp>
#include <iostream>

int main (void) {
	int n;
	int rowTest;
	double error;
	int iterations;

	std::cout.setf(std::ios::fixed, std::ios::floatfield);
    std::cout.precision(6);

	std::cin >> n >> rowTest >> error >> iterations;

	std::vector<std::vector<double> > A(n, std::vector<double>(n));
	std::vector<double> B(n);
	std::vector<double> x(n,0.0);


	// Le valores da matriz a partir do standar input
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			std::cin >> A[i][j];
	for (int i = 0; i < n; i++)
		std::cin >> B[i];

	// Cria solucionador Jacobi
	SeqJacobi jacobi(A,B,x,error,iterations);

	// Resolve o problema
	x = jacobi.solve(&iterations);

	// Calcula rowtest
	double rowTestResult = 0.0;
	for (int i = 0; i < n; i++)
		rowTestResult += x[i] * A[rowTest][i];

	// Imprime resultado
	std::cout << "Iterations: " << iterations << std::endl;
	std::cout << "RowTest: " << rowTest << "=> [" <<
				rowTestResult << "] =? " << B[rowTest] << std::endl;


	return 0;
}
